//
//  APSwiftTests.swift
//  APSwiftTests
//
//  Created by AbnerPei on 2021/12/23.
//
/*
 相关链接：
 - [swift单元测试（二）XCTest框架之单元测试UnitTest](https://blog.csdn.net/lin1109221208/article/details/91955462)
 */

import XCTest

class APSwiftTests: XCTestCase {
    
    var f1: Float?
    var f2: Float?
    
    override func setUp() {
        super.setUp()
        /// 在测试方法执行前设置变量
        f1 = 10.0
        f2 = 20.0
    }

    override func tearDown() {
        /// 在测试方法执行完成后，清除变量
        super.tearDown()
    }

    override func setUpWithError() throws {
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDownWithError() throws {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }

    func testExample() throws {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
        // Any test you write for XCTest can be annotated as throws and async.
        // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
        // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
        XCTAssertTrue(f1! + f2! == 30)
        XCTAssertTrue(f1! + f2! == 40, "10 + 20 怎么可能等于40")
    }
    
    //simpleTest
    func testIsPrimenumber(){
        let oddNumber = 6
        XCTAssertTrue(isPrimenumber(Double(oddNumber)))
    }
    func isPrimenumber(_ number : Double)->Bool{
        for no in 1...Int(sqrt(number)) {
            if Int(number)/no != 0{
                return true
            }
        }
        return false
    }

    func testPerformanceExample() throws {
        // This is an example of a performance test case.
        measure {
            // Put the code you want to measure the time of here.
        }
    }

}
